#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N], deg[N], num;
map<int, int> id;
int head[N];
int ver[N << 1], Next[N << 1], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
void dfs(int u, int fu) {
  for (int i = head[u]; i; i = Next[i]) {
    int v = ver[i];
    if (v == fu) continue;
    dfs(v, u);
  }
  cout << a[u] << ' ';
}
void solve() {
  cin >> n;
  id.clear();
  num = 0, tot = 0;
  rep(i, 1, n) {
    int x, y;
    cin >> x >> y;
    if (!id[x]) {
      id[x] = ++num;
      a[num] = x;
    }
    if (!id[y]) {
      id[y] = ++num;
      a[num] = y;
    }
    x = id[x], y = id[y];
    add(x, y), add(y, x);
    deg[x]++, deg[y]++;
  }
  int st = 0;
  rep(i, 1, num) {
    if (deg[i] == 1) {
      st = i;
      break;
    }
  }
  dfs(st, 0);
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}